import Text.Show.Functions

-- Y combinators
newtype SelfApply t = SelfApply { selfApply :: SelfApply t -> t } 
y :: (t -> t) -> t 
y f = selfApply term term 
      where term = (SelfApply $ \x -> f (selfApply x x)) 


-- I combinators
id :: a -> a 
id x = x  

-- B combinators(composition combinator)
b x y z = x ( y z )             

-- K combinators(constant combinator (const in Haskell))
k x y = x                       
k2 x y = y                       

-- W combinators(diagonalizing combinator)
w x y = x y y                   

-- S combinators(stronger composition combinator)
s x y z = x z ( y z )           

-- swap combinator (flip in Haskell)
c x y z = x z y                 

-- increment
p x = x + 1                     

-- summa
u x y = x + y    

-- Example usage
v = k (w u)

-- Sample
t1 = (App (Lam "x" $ Lam "y" $ Var "x") (Lam "z" $ Var "z"))


